const { defineConfig } = require('@vue/cli-service')
const path = require('path')
const resolve = (name) => (
  path.join(__dirname, name)
)
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    host: 'localhost',
    port: 2000,
    open: true,
    proxy: {
      '/api': {
        target: 'https://www.fastmock.site/mock/3e51e8c72602fead516e20f5d2456bcd',
        // 是否切换源
        changeOrigin: true,
        // 请求前缀的路径重写
        pathRewrite: {
          '^/api': '/api'
        }
      }
    }
  },
  lintOnSave: false,
  chainWebpack: (config) => {
    // 给路径起别名
    config.resolve.alias
      .set('@', resolve('./src'))
      .set('@c', resolve('src/components'))
      .set('@v', resolve('src/views'))
      .set('@a', resolve('src/api'))
      .set('@u', resolve('src/utils'))
  }
})
